{% extends 'base_children.html' %}
{% load mytags %}
{% block content %}
    <div class="layui-row larryms-panel auth-user-add">
        <form action="{% url 'api_mysql_instance' %}" class="layui-form layui-form-pane" method="post" id="demoAddForm">
            {% csrf_token %}


        <input class="layui-input" name='id' value="{{ data.id }}" type="text" hidden>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">集群</label>
                    <div class="layui-input-block">
                        <input class="layui-input" name='db_cluster' value="{{ db_cluster }}" type="text" disabled>
                    </div>
                </div>
            </div>

                 <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">实例标签</label>
                    <div class="layui-input-block">
                        <input class="layui-input" name='dbtag' value="{{ data.dbtag }}" type="text" >
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">IP</label>
                    <div class="layui-input-block">
                        <input class="layui-input" name='m_ip' value="{{ data.m_ip }}" type="text" disabled>
                    </div>
                </div>
            </div>
                 <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">port</label>
                    <div class="layui-input-block">
                        <input class="layui-input" name='port' value="{{ data.port }}" type="text" disabled>
                    </div>
                </div>
            </div>


            <div class="larryms-layer-btn">
                {#                    <a class="layui-btn layui-btn layui-btn-sm  layui-btn-normal" id="testconn">测试连接</a>#}
                <a class="layui-btn layui-btn layui-btn-sm left" lay-submit="" lay-filter="demoadd" id="submitAdd">确定</a>
                <a class="layui-btn layui-btn layui-btn-sm  layui-btn-danger" id="closeAdd">关闭</a>
            </div>


        </form>
    </div>

{% endblock %}
{% block self_foot %}
    <script type="text/javascript">
        layui.config({
            version: "2.0.8",
            base: '/static/larryms/',
            layertype: 2, //iframe内层弹窗类型不显示返回首页
            rightMenu: false // false关闭，设置为custom时使用自定义，不使用默认menu
        }).extend({
            larry: 'js/base'
        }).use(['larry', 'layer', 'form'], function () {
            var $ = layui.$,
                larry = layui.larry,
                table = layui.talbe,
                larryms = layui.larryms,
                form = layui.form;

            var curIfr = parent.layer.getFrameIndex(window.name);

            $('#closeAdd').on('click', function () {
                parent.layer.close(curIfr);
            });


            form.on('submit(demoadd)', function (data) {
                  $.ajax({
			    dataType: "JSON",
			    url:data.form.action, //请求地址
			    type:"PUT",  //提交类似
			    contentType: "application/json",
			    data: JSON.stringify(data.field),  //提交参数
			    success:function(res){
				larryms.msg(res.msg)
                   parent.table.reload('demo', {});
                            parent.layer.close(curIfr);
			},
	    	error:function(response){
				larryms.msg( response.responseText);
	    	}
		});
                  return false;
            });

        });


    </script>

{% endblock %}